package com.wlsk.license.common.execl.converter;


import cn.idev.excel.converters.Converter;
import cn.idev.excel.enums.CellDataTypeEnum;
import cn.idev.excel.metadata.GlobalConfiguration;
import cn.idev.excel.metadata.data.WriteCellData;
import cn.idev.excel.metadata.property.ExcelContentProperty;

import java.util.Objects;

/**
 * <p>@Description : Long转String</p>
 * <p>@Author : Zhangbin.Liu </p>
 * <p>@Date : 2019/9/3 16:27 </p>
 */
public class LongToStringConverter implements Converter<Long> {


    @Override
    public Class<Long> supportJavaTypeKey() {
        return Long.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return CellDataTypeEnum.STRING;
    }

    @Override
    public WriteCellData<String> convertToExcelData(Long value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        String result = "";
        if (!Objects.isNull(value)) {
            result = value.toString();
        }
        return new WriteCellData<>(result);
    }
}
